Напишите функцию sum_range(start, end), которая суммирует все целые числа от значения «start» до величины «end» включительно. Если пользователь задаст первое число большее чем второе, просто поменяйте их местами.
При решении удобно воспользоваться встроенными функциями range() и sum().
Решение:
def sum_range(start, end): if start > end: end, start = start, end return sum(range(start, end + 1))
# Тесты print(sum_range(2, 12)) print(sum_range(-4, 4)) print(sum_range(3, 2)) Результат выполнения: 77 0 5 Свой вариант решения в комментарии 💬
Напишите функцию sum_range(start, end), которая суммирует все целые числа от значения «start» до величины «end» включительно. Если пользователь задаст первое число большее чем второе, просто поменяйте их местами.
При решении удобно воспользоваться встроенными функциями range() и sum().
Решение:
def sum_range(start, end): if start > end: end, start = start, end return sum(range(start, end + 1))
# Тесты print(sum_range(2, 12)) print(sum_range(-4, 4)) print(sum_range(3, 2)) Результат выполнения: 77 0 5 Свой вариант решения в комментарии 💬
#задачи
BY Python Turbo. Уютное сообщество Python разработчиков.
For some time, Mr. Durov and a few dozen staffers had no fixed headquarters, but rather traveled the world, setting up shop in one city after another, he told the Journal in 2016. The company now has its operational base in Dubai, though it says it doesn’t keep servers there.Mr. Durov maintains a yearslong friendship from his VK days with actor and tech investor Jared Leto, with whom he shares an ascetic lifestyle that eschews meat and alcohol.
A Telegram spokesman declined to comment on the bond issue or the amount of the debt the company has due. The spokesman said Telegram’s equipment and bandwidth costs are growing because it has consistently posted more than 40% year-to-year growth in users.
Python Turbo Уютное сообщество Python разработчиков from jp